#!/bin/bash

TOP_DIR := .
INC_DIR := -I$(TOP_DIR)/include  
TARGET := tst
VPATH += src
PLATFORM ?= linux64
LIB_DIR := $(TOP_DIR)/lib

GLOBAL_PREFIX = 
CROSS_COMPILE = $(GLOBAL_PREFIX)
CC = $(CROSS_COMPILE)gcc
CPP = $(CROSS_COMPILE)g++
AR  = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib

CFLAGS += $(INC_DIR) -g
# CFLAGS += -DSUPPORT_DISPLAY 
# CFLAGS += -DSUPPORT_SAVE_STREAM 
# CFLAGS +=  -DSUPPORT_TIMESTAMP 

LDFLAGS = -L$(LIB_DIR) 
#LDFLAGS += -lrtpdepay -lrtspc -lhpr -lradar -ltztek
##sys##
#LDFLAGS += -lpthread
#LDFLAGS += -Wl,-rpath=$(LIB_DIR)


	
#creat bin
#BIN := $(shell if [ ! -d $(BIN_DIR) ]; then mkdir $(BIN_DIR) ; fi)
 
# get cpp and c file name
SOURCES := $(foreach dir,$(VPATH),$(wildcard $(dir)/*))
C_SRCS   = $(filter %.c,$(SOURCES))
CPP_SRCS = $(filter %.cpp,$(SOURCES))


# get src and obj file name
C_OBJS   = $(C_SRCS:%.c=%.o)
CPP_OBJS = $(CPP_SRCS:%.cpp=%.o)
OBJS := $(C_OBJS) $(CPP_OBJS)


#complie src file
%.o:%.c
	$(CC)  -c $(CFLAGS) $< -o $@  
	
%.o:%.cpp
	$(CPP) -c $(CFLAGS) $< -o $@


#build

all: $(TARGET)
$(TARGET): $(OBJS)
	$(CPP)  -g   -o $(TARGET) $(OBJS) $(LDFLAGS)

	

proj:
	make 
clean:
	-rm -f $(TARGET) $(OBJS)
	




	

